﻿using System;
using System.Collections.Generic;
using Gameplay.PVE.Utils;
using UnityEngine;
using XLua;
using Yoozoo.Framework.Core;

namespace Gameplay.PVE.Survivor
{
    public class RpgMissionStageConfig
    {
        public int id;
        public int stage;
        public int stage_type;
        public List<int> stage_value;
        public List<int> task_group;
        public List<int> events;
        public int start_point_id;
        public string map;
        public List<float> camera_follow;
        public List<float> camera_track;
        public List<float> camera_near_far;
        public List<float> camera_track_h;
        public int client_report;
    }
    
    public partial class BattleConfigManager
    {
        private Dictionary<int, Dictionary<int,RpgMissionStageConfig>> missionStageMap;
        public RpgMissionStageConfig GetStageConfig(int id,int subId)
        {
            if (missionStageMap.TryGetValue(id,out var config))
            {
                if (config.TryGetValue(subId,out var subConfig))
                {
                    return subConfig;
                }
            }

            if (BattleDebug.enableLog)
            {
                BattleDebug.LogError("阶段找不到" + id + " " + subId);
            }
            return null;
        }

        public Dictionary<int, RpgMissionStageConfig> GetStageConfigs(int id)
        {
            if (missionStageMap.TryGetValue(id,out var config))
            {
                return config;
            }
            if (BattleDebug.enableLog)
            {
                BattleDebug.LogError("阶段找不到" + id);
            }
            return null;
        }
        
        public static void PreloadRpgMissionStageConfig(LuaTable table)
        {
            PveUtils.PreloadRpgConfigWithSubKey(table,ref Instance.missionStageMap,"id","stage");
        }
    }
}
